package Day05;

import java.util.Arrays;

public class ArraysPractice {
    public static void main(String[] args) {
        for (int a=1;a<10;a++){
            for (int b=1;b<=a;b++){
                System.out.print(a+"*"+b+"="+a*b+"\t");
            }
            System.out.println();
        }
        System.out.println("-------------------------");
        int[]arr=new int[4];
        int[]arr1={2,3,4,5,6};
        for (int i=0;i<arr.length;i++){
            arr[i]=100+i;
            System.out.println(arr[i]);
        }
        System.out.println("-------------------------");
        //System.arraycopy(arr,0,arr1,0,4);
        arr1= Arrays.copyOf(arr,4);
        for (int i=0;i<arr1.length;i++){
            System.out.println(arr1[i]);
        }
        System.out.println("-------------------------");
        int[]a=new int[10];
        int max=a[0];
        for (int i=1;i<a.length;i++){
            a[i]=(int)(Math.random()*100);
            if (max<a[i]){
                max=a[i];
            }
            System.out.println(a[i]);
        }
        System.out.println("最大数为"+max);
        a=Arrays.copyOf(a,a.length+1);
        a[a.length-1]=max;
        for (int i=0;i<a.length;i++){
            System.out.println(a[i]);
        }
        System.out.println("------------------");
        Arrays.sort(a);
        for (int i=0;i<a.length;i++){
            System.out.println(a[i]);
        }
    }
}
